/*
 *@(#)RssImpl.java 1.0 Mar 27, 2008
 *Copyright Fution Bai
 *
 */
package codebush.service.impl;

import java.util.List;

import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
import org.springframework.jdbc.support.rowset.SqlRowSet;

import codebush.domain.Article;
import codebush.service.Rss;
import codebush.service.support.rowMapper.RowMapperForArticle;

/**
 *
 * @author Fution Bai
 * @since 1.0
 */
public class RssImpl extends SimpleJdbcDaoSupport implements Rss {

	public Object rss(int userId) {
		String sql = "select id, title, content from article where user_id=? and post_time  > DATE_SUB(curdate(), INTERVAL 180 DAY);";
		Object[] args = {userId};
		SqlRowSet srs = getJdbcTemplate().queryForRowSet(sql, args);
		String[] columns = {"id", "title", "content"}; 
		List<Article> list = RowMapperForArticle.getInstance().mapRowForSpecificColumns(srs, columns, 0);
		return list;
	}

}
